package com.tanxin.bill.common.base;

import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.widget.FrameLayout;

import com.tanxin.bill.R;
import com.tanxin.bill.modules.BillListActivity;
import com.tanxin.bill.modules.CustomerListActivity;

public abstract class BaseDrawActivity extends BaseActivity {
    protected DrawerLayout rootLayout;
    protected FrameLayout flActivityContainer;

    @Override
    protected void setBaseView() {
        contentView = LayoutInflater.from(this).inflate(R.layout.base_drawer_activity, null);
        setContentView(contentView);

        rootLayout = findViewById(R.id.root_layout);
        flActivityContainer = findViewById(R.id.activity_container);
        flActivityContainer.addView(LayoutInflater.from(this).inflate(bindLayout(), flActivityContainer, false));
        NavigationView navigationView = findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.tv_bill:
                        BillListActivity.startActivity(getContext());
                        break;
                    case R.id.tv_customer:
                        CustomerListActivity.startActivity(getContext(),0);
                        break;
                    default:
                        break;
                }
                return false;
            }
        });
    }
}
